package com.dstz.demo.rest.controller;

import com.dstz.base.rest.BaseController;
import com.dstz.demo.core.manager.BudgetManager;
import com.dstz.demo.core.manager.ContentManufacturerManager;
import com.dstz.demo.core.manager.ProcurementPlanningManager;
import com.dstz.demo.core.model.BudgetContent;
import com.dstz.demo.core.model.ContentManufacturer;
import com.dstz.demo.core.model.ProcurementPlanning;
import com.dstz.sys.util.ContextUtil;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/sys/procurementplanning")
public class ProcurementPlanningController extends BaseController<ProcurementPlanning> {
    @Resource
    ProcurementPlanningManager procurementPlanningManager;
    @Resource
    BudgetManager budgetManager;
    @Resource
    ContentManufacturerManager contentManufacturerManager;
    protected String getModelDesc() {

        return null;
    }
    @PostMapping("/getinfo")
    public List<ProcurementPlanning> getinfo(){
        Map<String,Object> map=new HashMap<>();
        map.put("userid", ContextUtil.getCurrentUserId());
        map.put("projectid","1");
        List<ProcurementPlanning> maps=procurementPlanningManager.map(map);
        return maps;
    }

    @PostMapping("/save")
    public String saves(@RequestBody ProcurementPlanning procurementPlanning, @RequestBody BudgetContent budgetContent, @RequestBody ContentManufacturer contentManufacturer){
        procurementPlanningManager.save(procurementPlanning);
        budgetManager.save(budgetContent);
        contentManufacturerManager.save(contentManufacturer);
        return "添加成功";
    }
}
